<?php include '../conn.php'; ?>
<!--预加载的script文件-->
<div id="script-file">
    <script data-src="./js/department.js"></script>
</div>
<div class="department-container container">
    <div class="department-sidebar">
        <div class="department-logo">
            <img src="./images/department_logo.jpg" alt="">
        </div>
        <div class="cate-menu">
            <div class="swiper-container gallery-thumbs">
                <div class="swiper-wrapper">
                    <?php

                    $query = "select * from tb_category where level = 1";
                    //查询二级栏目
                    $category_res_1 = mysqli_query($link, $query);
                    while ($row1 = mysqli_fetch_array($category_res_1)) {
                        $row1_path = $row1['path'];
                        $row1_id_arr = explode(',', $row1_path);
                        $row1_id = end($row1_id_arr);
                        if ($row1_id == $cateId) {
                            ?>
                            <div class="swiper-slide"  data-hash="<?php echo $cateNo . '?id=' . $row1['id'] ?>"
                                 data-cateId="<?php echo $row1['id']; ?>"><?php echo $row1['categoryName']; ?></div>
                            <?php
                        }
                    }

                    ?>
                </div>
                <div class="right-more" tabindex="0" role="button" aria-label="Next slide" aria-disabled="false">
                    <span class="glyphicon glyphicon-chevron-right"></span>
                </div>
            </div>
        </div>
    </div>
    <div class="cate-menu-content">
        <div class="swiper-container gallery-top">
            <div class="swiper-wrapper">
                <?php
                //一级栏目id
                $query_cate = "select * from tb_category where level = 1";
                //查询二级栏目
                $category_res_1 = mysqli_query($link, $query_cate);
                while ($row1 = mysqli_fetch_array($category_res_1)) {
                    $row1_path = $row1['path'];
                    $row1_id_arr = explode(',', $row1_path);
                    $row1_id = end($row1_id_arr);
                    if ($row1_id == $cateId) {
                        $query_news = "select * from tb_news where categoryNo = " . $row1['id'];
                        $news_res = mysqli_query($link, $query_news);
                        $news_row = mysqli_fetch_array($news_res);
                        ?>
                        <div class="swiper-slide"  data-hash="<?php echo $cateNo . '?id=' . $row1['id'] ?>">
                            <h4 class="cate-title"><?php echo $news_row['title'] ?></h4>
                            <div class="cate-body">
                                <?php echo $news_row['body']; ?>
                            </div>
                        </div>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
    </div>
</div>

